/*
*Copyright 2021-2023 NERCIS
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/

package cn.ac.nercis.pes.common.constant.knowledge;

import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * 指标密级
 * @author zpy
 * @version 1.0.0
 */
public enum TargetLevel {
    /**
     *
     */
    DEFAULT(0,""),
    /**二级**/
    G2(2,"二级"),
    /**三级**/
    G3(3,"三级"),
    /**四级**/
    G4(4,"四级");

    private final int targetLevel;
    private final String name;

    TargetLevel(int targetType, String name) {
        this.targetLevel = targetType;
        this.name = name;
    }

    public static TargetLevel fromLevel(Integer targetLevel){
        TargetLevel data = DEFAULT;
        for(TargetLevel tt :TargetLevel.values()){
            if(tt.targetLevel == targetLevel){
                data = tt;
                break;
            }
        }
        return data;
    }

    public static List<TargetLevel> findLevels(){
        return List.of(G2,G3,G4);
    }

    public static TargetLevel fromName(String name){
        TargetLevel data = DEFAULT;
        for(TargetLevel tt :TargetLevel.values()){
            if(StringUtils.equals(tt.name,name)){
                data = tt;
                break;
            }
        }
        return data;
    }

    public int getTargetLevel(){
        return this.targetLevel;
    }

    public String getName(){
        return this.name;
    }
}